home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / CRC_TC.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  1KB  |  36 lines

  1. ;================================================
  2. ; CRC Generation Subroutine for Turbo C
  3. ;
  4. ; This is a code fragment to update a 16 bit CRC
  5. ; value by one byte.  To use in Turbo C, perform
  6. ; the following steps:
  7. ;
  8. ;   WASM crc_tc
  9. ;   CONVERT c < crc_tc.com > temp
  10. ;   DEL crc_tc.com
  11. ;
  12. ; Now the machine code is in text format in the
  13. ; file TEMP.  Use this code as follows:
  14. ;
  15. ;   void far CRC16 (unsigned int far *crc, char data)
  16. ;   {
  17. ;     __emit__ (
  18. ;       { insert the contents of file TEMP here }
  19. ;     )
  20. ;   }
  21.  
  22. CRCGEN  EQU     1021H   ;xmodem CRC bit pattern
  23.  
  24.         push    ds              ;DS must be saved
  25.         mov     al, [bp+10]     ;load data byte
  26.         lds     bx, [bp+6]      ;load address of CRC value
  27.         mov     dx, [bx]        ;load current CRC value
  28.         mov     cx, 8           ;bits to process
  29. a1      shl     al              ;shift bit into carry
  30.         rcl     dx              ;roll into checksum
  31.         jnc     a2              ;skip xor if bit not shifted out
  32.         xor     dx, CRCGEN      ;xor CRC value
  33. a2      loop    a1              ;loop for each bit in byte
  34.         mov     [bx], dx        ;save CRC value
  35.         pop     ds              ;restore DS
  36.